<?php

class CalculatorController extends Zend_Controller_Action
{

    public function init()
    {
        $this->_helper->contextSwitch()
                        ->addActionContext('showhandlytypes', 'json')
                        ->addActionContext('showsystemcolors', 'json')
                        ->addActionContext('showsystemparams', 'json')
                        ->initContext();
    }

    public function indexAction()
    {
        $this->view->headLink()->appendStylesheet('/stylesheets/calculator.css');
        $this->view->headScript()->appendFile($this->view->baseUrl('/frameworks/jquery/js/jquery-1.7.2.min.js'));
        $this->view->headScript()->appendFile($this->view->baseUrl('/js/calculator/2D.js'));
        $this->view->headScript()->appendFile($this->view->baseUrl('/js/calculator/calculator7.js'));
    }
    
    public function showhandlytypesAction()
    {
        $conf_logic = Zend_Registry::getInstance()->conf_logic;
        $this->view->path_handly_specs = $conf_logic->path->handly_specifications;
        
        $hanlySpecsService = Application_Model_HandleSpecificationsService::getInstance();
        $hanlySpecsPaginator = $hanlySpecsService->getPaginatorRows();
        $pageId = (int) $this->getRequest()->getParam('page');
        if (isset($pageId))
        {
            $hanlySpecsPaginator->setCurrentPageNumber($pageId);
        }
        $this->view->paginator = $hanlySpecsPaginator;
        $this->view->handly_types = $hanlySpecsPaginator->getCurrentItems();
    }

    public function dialogAction()
    {
        
    }

    public function showsystemcolorsAction()
    {
        $conf_logic = Zend_Registry::getInstance()->conf_logic;
        $textures_service = Application_Model_TexturesService::getInstance();
        $this->view->path_textures = $conf_logic->path->textures;
        $this->view->system_textures = $textures_service->find_by_type(0)->toArray();;
    }

    public function showsystemparamsAction()
    {
        $conf_logic = Zend_Registry::getInstance()->conf_logic;
        $this->view->cornice_width = $conf_logic->system->cornice_width;
        $this->view->threshold_width = $conf_logic->system->threshold_width;
        $this->view->top_indentation = $conf_logic->system->top_indentation;
        $this->view->bottom_indentation = $conf_logic->system->bottom_indentation;
        $this->view->top_door_offset = $conf_logic->system->top_door_offset;
        $this->view->bottom_door_offset = $conf_logic->system->bottom_door_offset;
        $this->view->fill_capture = $conf_logic->system->fill_capture;
        $this->view->splitter_fill_capture = $conf_logic->system->splitter_fill_capture;
        $this->view->base_width_splitter = $conf_logic->system->base_width_splitter;
    }


}